var common = require("../../utils/Conmon.js");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: {},
    ObjectID: 0,
    ObjectType: 1,
    CustID: 0
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var _this = this;

    var ObjectType = 1;
    var ObjectID = 0;
    if (options.ObjectType > 0) {
      ObjectType = options.ObjectType;
    }
    if (options.ObjectID > 0 && ObjectType > 1) {
      ObjectID = options.ObjectID;
    }
    var globalData = getApp().globalData;
    var custId = globalData.custID;

    this.setData({
      CustID: globalData.custID,
      ObjectID: ObjectID
    });

    var postData = {
      custID: globalData.custID,
      Platform: "MiniWxAPP",
      ObjectID: ObjectID,
      ObjectType: ObjectType,
      type: "Home",
      CustSystemID: globalData.SystemId
    };
    wx.request({
      url: globalData.apiurl + '/magic/api/MagicMall/DefaultJson',
      data: JSON.stringify(postData),
      method: 'post',
      
      header: {
        'content-type': 'application/json',
        'X_ManuName': globalData.manuName
      },
      success: function(res) {
        if (res.data.content != null && res.data.content!=undefined){
          var page = JSON.parse(res.data.content);
          _this.setData({
            page: page
          });
          wx.setNavigationBarTitle({
            title: page.Title,
          })
        }
        
        // console.log(page);
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

    this.dialog = this.selectComponent("#dialog");
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
     common.pageInit(function () { });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },



  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})